#ifndef _GSM_H
#define _GSM_H

#include "GPIO.h"
#include "stm32f10x.h"
#include "UART.h"
#include "main.h"

#define GSMnPIN                             4
  
#define GSM_PWRKEY_PIN            GPIO_Pin_1
#define GSM_PWRKEY_PORT         GPIOA
#define GSM_PWRKEY_CLK            RCC_APB2Periph_GPIOA 

#define GSM_STATUS_PIN            	GPIO_Pin_8
#define GSM_STATUS_PORT         	GPIOB
#define GSM_STATUS_CLK            	RCC_APB2Periph_GPIOB 

#define GSM_RI_PIN				GPIO_Pin_12
#define GSM_RI_PORT        		GPIOB
#define GSM_RI_CLK           		RCC_APB2Periph_GPIOB

#define GSM_DTR_PIN            		GPIO_Pin_9
#define GSM_DTR_PORT         		GPIOB
#define GSM_DTR_CLK            		RCC_APB2Periph_GPIOB 

typedef enum 
{
	GSM_PWRKEY = 0,
	GSM_STATUS = 1,
	GSM_RI = 2,
	GSM_DTR = 3
} Output_TypeDef;

void GSMInitController(void);
void GSM_PWRKEY_On(void);
void GSM_PWRKEY_Off(void);
uint32_t GSM_GetStatus(void);
uint32_t GSM_GetRI(void);

void UART_GSM_ISR(void);
void UART_GSM_SendByte(uint8_t data);
void UART_GSM_SendString(uint8_t *data);
uint8_t UART_GSM_ReceivedByte(void);
void UART_GSM_ReceivedString(uint8_t *data_buff, uint8_t data_len);
uint8_t UART_GSM_RXAvailable(void);
void UART_GSM_RXFlush(void);

#endif

